#include<stdio.h>
int run(int year1,int year2)
{
	if(year1==year2 && year1==0 )
		return 1;
	else if((year1*10+year2)>=60 && (year1*10+year2+1900)%4==0)
		return 1;
	else if((year1*10+year2)<=59 && (year1*10+year2 )%4==0)
		return 1;	
	else 
		return 0;		 
}
void print(int year1,int year2,int mouth1,int mouth2,int day1,int day2)
{
	if((year1*10+year2)>=60)
		printf("19%d%d-%d%d-%d%d\n",year1,year2,mouth1,mouth2,day1,day2);
	else
		printf("20%d%d-%d%d-%d%d\n",year1,year2,mouth1,mouth2,day1,day2);	
}
void judge(int year1,int year2,int mouth1,int mouth2,int day1,int day2)
{
	if(mouth1*10+mouth2<=12 && day1*10+day2<=31)
	{
		switch(mouth1*10+mouth2)
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:	
			case 10:	
			case 12:	
				if(day1*10+day2<=31)
				{
					print(year1,year2,mouth1,mouth2,day1,day2);
				}
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				if(day1*10+day2<=30)
				{
					print(year1,year2,mouth1,mouth2,day1,day2);
				}
				break;
			case 2:
				if(run(year1,year2)==1 && day1*10+day2<=29)
					print(year1,year2,mouth1,mouth2,day1,day2);
				if(run(year1,year2)==0 && day1*10+day2<=28)
					print(year1,year2,mouth1,mouth2,day1,day2);	
				
		}
	}
}

int main()
{
	int num1=0,num2=0,num3=0;
	int num4=0,num5=0,num6=0;
	scanf("%d-%d-%d-%d-%d-%d",&num1,&num2,&num3,&num4,&num5,&num6);
	judge(num1,num2,num3,num4,num5,num6);
	judge(num5,num6,num1,num2,num3,num4);
	judge(num5,num6,num3,num4,num1,num2);
	return 0;
}